<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();%>
<script type="text/javascript">
var allPicArray = new Array();
var old_pic = "${webFileVO.fileName}";
function confirmAddPicContent(args){
	var fileName = args["fileName"];
	var fileSize = args["fileSize"];
	var arg1 = "pic_div_content_";
	var str = '<div id="'+arg1+'" style="border:1 solid #ccc;margin-top:5px;margin-bottom:5px;padding:5px;width:400px">';
	str += '<b style="margin-left:15px">文件大小：</b>'+fileSize+'KB<b style="margin-left:15px">文件：</b>'+fileName;
	str += '</div>';
	$("#"+arg1).replaceWith($(str));
	$("input[name='webFileVO.fileName']").val(fileName);
	$("input[name='webFileVO.fileSize']").val(fileSize);
	$("input[name='oldPic']").val(old_pic);
	allPicArray.push(fileName);
}
function changeFileTYpe(type){
	if (type == 0) {
		$("#addFileP").css("display", "block");
		$("#addLinkP").css("display", "none");
	} else {
		$("#addFileP").css("display", "none");
		$("#addLinkP").css("display", "block");
	}
}
function setWebFileVOValue(obj) {
	var vals = $("input[name='linkType']:checked").val();
	if (vals == 0) {
		if ($("input[name='webFileVO.fileName']").val()==""){
			alert("请添加文件！");
			$('#add_pic_a_id').trigger('click');
			return false;
		}
		$("input[name='webFileVO.linkFile']").val("");
		allPicArray.splice($.inArray($("input[name='webFileVO.fileName']").val(),allPicArray),1);
	}
	else {
		if ($("input[name='webFileVO.linkFile']").val()=="") {
			alert("请输入链接地址！");
			$("input[name='webFileVO.linkFile']").focus();
			return false;
		}
		$("input[name='webFileVO.fileName']").val("");
		$("input[name='webFileVO.fileSize']").val("0.0");
	}
	$("input[name='removePics']").val(allPicArray.join(","));
	return validateCallback(obj, navTabAjaxDone);
}
</script>
	<div class="pageContent">
		<form method="post" action="<%=path%>/webManager/saveFile.action" class="pageForm required-validate" onsubmit="return setWebFileVOValue(this);">
			<input type="hidden" name="webFileVO.fileName" value="${webFileVO.fileName}"/>
			<input type="hidden" name="webFileVO.type" value="${webFileVO.type}"/>
			<input type="hidden" name="webFileVO.fileSize" value="${webFileVO.fileSize}"/>
			<input type="hidden" name="webFileVO.id" value="${webFileVO.id}"/>
			<input type="hidden" name="removePics"/>
			<input type="hidden" name="oldPic"/>
			<div class="pageFormContent" layoutH="56" style="width: 98%">
				<p style="width: 50%">
					<label>文件名称：</label>
					<input type="text" name="webFileVO.name" value="${webFileVO.name}" class="required" alt="请输入文件名称" size="30"/>
				</p>
				<p style="width: 50%">
					<label>链接方式：</label>
					<input type="radio" name="linkType" value="0" onclick="changeFileTYpe(this.value);"${webFileVO.linkFile==null?" checked='true'":""}/>自传文件
					<input type="radio" name="linkType" value="1" onclick="changeFileTYpe(this.value);"${webFileVO.linkFile==null?"":" checked='true'"}/>引用链接
				</p>
				<div class="divider" style="border:0;height:70px"></div>
				<p id="addLinkP" style="width: 50%;display: none">
					<label>链接地址：</label>
					<input type="text" name="webFileVO.linkFile" value="${webFileVO.linkFile}" size="30"/>
				</p>
				<div id="addFileP" style="width: 100%;display: none">
					<label>程序文件：</label>
					<a class="button" onclick="$('#add_pic_a_id').trigger('click');"><span>添加文件</span></a>
					<a id="add_pic_a_id" class="btnAttach" href="<%=path%>/jsp/webManager/pic/pic_upload.jsp?folder=webIndexFile" lookupGroup="" width="560" height="300" style="display: none"></a>
					<div class="divider" style="border:0"></div>
					<div id="pic_content_div" style="float: none;width:auto;padding-left: 150px;">
						<div id="pic_div_content_" style="border:1 solid #ccc;margin-top:5px;margin-bottom:5px;padding:5px;width:400px">
						<b style="margin-left:15px">文件大小：</b>${webFileVO.fileSize}KB
						<b style="margin-left:15px">文件名：</b>${webFileVO.fileName}
						</div>
					</div>
				</div>
			</div>
			<div class="formBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
					<li>
						<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
					</li>
				</ul>
			</div>
		</form>
	</div>
<script type="text/javascript">
if ("${webFileVO.linkFile}"=="")
	changeFileTYpe(0);
else
	changeFileTYpe(1);
</script>